package com.hkemmm.backstage.controller;

import com.hkemmm.shop.entity.Admin;
import com.hkemmm.shop.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@RequestMapping("/admin")
@Controller
public class AdminController {
    @Autowired
    private IAdminService adminService;


    @RequestMapping("/login")
    @ResponseBody
    public Object login(String username, String password, HttpServletRequest request) {
        Admin admin = adminService.Login(username, password);

        if (admin == null) {
            return null;
        } else {
//            request.getSession().setAttribute("admin", admin);
            return admin;
        }
    }
}
